#include<stdio.h>
#define LEN 8

int binarySearch(int *arr, int start, int end, int number)
{
  while (start <= end){
    int mid = (start + end) / 2;
    if (arr[mid] == number){
      while (arr[mid--] == number){
        ; /*空语句*/
      }
      return mid + 2;
    }
    else if (arr[mid] < number){
      start = mid + 1;
    }
    else{
      end = mid - 1;
    }
  }
  
  return -1;
}

int main()
{
  int a[] = {1, 1, 2, 2, 5, 6, 8, 9};
  printf("%d\n", binarySearch(a, 0, 7, 1));
}
